<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class PictureBanController extends Controller
{
    public function ypBan(Request $request)
    {
        $type = $request->type;
        if (!$type) {
            return 0;
        }
        $uri = explode('/', $request->uri);
        $data = \Redis::get($uri[1]);
        $data = explode('/', $data);
        $md5 = $data[0];
        $sha1 = $data[1];
        if ($type == 'delete') {
            \Redis::del($md5);
            \Redis::del($sha1);
            \Redis::del($uri[1]);
        } elseif ($type == 'shield') {
            \Redis::set($md5, 'shield');
            \Redis::set($sha1, 'shield');
        } elseif ($type == 'cancel_shield') {
            \Redis::set($md5, $uri[1]);
            \Redis::set($sha1, $uri[1]);
        } else {
            return 0;
        }
        return 1;
    }
    public function redis(){
        $data = \Redis::keys('*');
        $data1 = array();
        foreach ($data as $vale){
            $data1[$vale] = \Redis::get($vale);
        }
        return view('redis',['data'=>$data1]);
    }
}
